num=2
def findComplement(num):
    res=0
    count=0
    while num!=0:
        # res<<=1
        if num&1==1:
            res+=0
        else:
            res+=1<<count
        num>>=1
        count+=1
    return res
print(findComplement(num))